package initialize

import (
	"go-backend-simple-scaffold/global"
	"go-backend-simple-scaffold/model/entity"
	"go.uber.org/zap"
	"gorm.io/gorm"
	"os"
)

func Gorm() *gorm.DB {
	return GormMysql()
}

func RegisterTables() {
	db := global.GBSS_DB
	err := db.AutoMigrate(
		entity.GbssUser{},
	)
	if err != nil {
		global.GBSS_LOG.Error("自动创建数据库表失败", zap.Error(err))
		os.Exit(0)
	}
	global.GBSS_LOG.Info("数据库表创建成功")
}
